<style scoped>
    .pro-con {
        padding: 0 30px;
        margin-bottom: 50px;
    }
    .pro-con .ivu-form-item{
        margin-bottom: 0;
    }
    .hr{
        border:0;
        background-color:#DEDEDE;
        height:1px;
        margin: 15px 0;
    }
    .pro-con .ivu-col{
        padding-right: 0 !important;

    }
    .fr{
        float: right;
    }
    .pro-pagesize .mr10{
        margin-right: 10px;
    }
    .search-h3{
        font-size: 18px;
        color: #ef8412;
        font-weight: normal;
        margin-bottom: 20px;
    }

    /* #footer{
        padding: 0 30px;
        height: 80px;
        line-height: normal;
        position: fixed;
        bottom: 0;
        z-index:999;
        text-align: center;
        background-color: #FFF;
        box-shadow: -1px -3px 2px #E3E3E3;
        margin-right: 15px;
        right:0;

    }
    #footer .page{
        height: 36px;
    }
    #footer .page .ivu-page-options{
        height: 36px !important;
    }
    #footer .page .ivu-page-options .ivu-page-options-sizer{
        height: 36px;
    } */
    /*//////////////////////////////*/

    .pro-card {
        margin-bottom: 10px;
    }
    .pro-card-head {
        background-color: #e6e7eb;
        line-height: 38px;
        border: 1px solid #ddd;
    }
    .pro-card-title {
        font-size: 14px;
        color: #333;
        font-weight: bold;
        padding-left: 20px;
    }
    .pro-card-headr {
        padding-right: 10px;
        text-align: right;
    }
    .pro-card-content {
        clear: both;
    }
    .pro-paramname {
        text-align: center;
        background-color: #e6e7eb;
        font-size: 14px;
        color: #333;
        border-right: 1px solid #ddd;
    }
    .pro-paramvalue {
        padding-left: 30px;
        border-right: 1px solid #ddd;
    }
    .pro-card-contentrow {
        line-height: 40px;
        border-left: 1px solid #ddd;
        border-bottom: 1px solid #ddd;
    }
    /* .fr{
        float: right;
    } */
    .mb10{
        margin-bottom: 10px;
    }
    .search-h3{
        font-size: 18px;
        color: #ef8412;
        font-weight: normal;
        margin-bottom: 20px;
    }
    .search-form{
        border-bottom: 1px solid #d9d9d9;
    }
    .search-form .ivu-col{
        margin-bottom: 15px;
    }
    .clear{
        clear: both;
    }
    .table-theme{
        clear: both;
    }
    .table-action{
        padding-top: 10px;
        padding-bottom: 15px;
    }
    .inline-cut{
        margin-left: 15px;
        margin-right: 15px;
        width: 1px;
        height: 25px;
        background-color: #edf2f6;
    }
    .pro-pagesize{
        margin-bottom:10px;

    }
    .footer{
        position: fixed;
        padding: 0 30px;
        bottom:0;
        background-color:#FFF;
        box-shadow: -1px -3px 2px #E3E3E3;
    }
    .pro{
    }
    .pro_head_img{
    }
    .pro_show_img{
        position: relative;
        height:120px;
    }
    .close{
        width:15px;
        height:15px;
        position: absolute;
        right:7px;top:7px;
        border-radius: 50%;
        background-color:red;
        color:#FFF;
        line-height:15px;
        text-align: center;
        cursor: pointer;
    }
    .imgAdd{
        border:1px dotted #EEEEEE;
        height:50px;
        margin-top:10px;
        line-height: 50px;
        text-align: center;
        background-color: #FBFCFE;
    }
    .site-wrapper {
        width: 95%;
        margin: 0 auto;
    }
    .bm-view {
        width: 100%;
        height: 300px;
        margin-bottom: 20px;
    }
    .cropper-wrapper {
        margin-top: 10px;
        height: 400px;
    }
    .cropper-box{
        height: 300px;
    }
    .btn {
        display: inline-block;
        line-height: 1;
        white-space: nowrap;
        cursor: pointer;
        text-align: center;
        box-sizing: border-box;
        outline: none;
        margin:20px 10px 0px 0px;
        padding: 9px 15px;
        font-size: 14px;
        border-radius: 4px;
        color: #fff;
        background-color: #50bfff;
        border-color: #50bfff;
        transition: all .2s ease;
        text-decoration: none;
        user-select: none;
    }
    .iconclass{
        display: inline-block;
        width: 58px;
        background: #fff;
        border: 1px dashed #dddee1;
        border-radius: 4px;
        text-align: center;
        cursor: pointer;
        position: relative;
        overflow: hidden;
        transition: border-color .2s ease;
        height:58px;
        line-height: 58px;
    }
    .cailiao{
        margin: 10px 0px 15px ;
    }
    .cailiao span:first-child{
        display: inline-block;
        width: 20%;
        height: 36px;
        line-height: 36px;
        font-size: 14px;
        border: 1px solid #A9A9A9;
        border-right: 0;
        text-align: center;
        vertical-align: middle;
        background-color: #FAFAFA;
        font-weight: 500;
    }
    .cailiao .inputBox{
        height: 36px;
        line-height: 34px;
        width: 80%;
        vertical-align: middle;
        padding-left: 5px;
        border:1px solid #A9A9A9;
        display: inline-block;
    }
    .cailiao .inputBox input{
        border: 0;
        width: 100%;
        outline: none;
    }

</style>
<style>
    .duty .ivu-date-picker-rel:after, .duty .ivu-select:after {
        content: "";
        position: absolute;
        top: 1px;
        bottom: 1px;
        right: 1px;
        width: 35px;
        height: 34px;
        border-left: 1px solid #bebebe;
        background-color: #FAFAFA;
    }
    .duty .ivu-form .ivu-form-item-label{
        border:1px solid #BEBEBE;
        border-right: 0;
        background-color: #FAFAFA;
    }
    .duty .ivu-select-single .ivu-select-selection,.duty .ivu-input{
        height: 36px ;
        line-height: 36px;
        border-radius: 0 2px 2px 0;
        border-color: #BEBEBE;
    }
    .duty .ivu-select-single .ivu-select-selection .ivu-select-placeholder,.duty .ivu-select-single .ivu-select-selection .ivu-select-selected-value{
        height: 34px ;
        line-height: 34px;
        padding-right: 34px;
    }
    .duty .ivu-select-arrow{
        right:12px;
        z-index: 9;
    }
    .duty textarea.ivu-input{
        height: inherit;
    }
    .modal5 .ivu-modal-footer{
        background-color: #F2F2F2;
    }
</style>
<template>
    <div class="pro-list">
        <product-title></product-title>
        <div class="pro-con">
            <div class="pro-con-f common-box-body">
                <Row>
                    <h3 class="search-h3 huang" >
                        {{this.$route.params.name}}的保险责任
                    </h3>
                    <Form  :model="searchForm" class="search-form">
                         <Col :xs="24" :sm="12" :md="12" :lg="15">
                            &emsp;
                         </Col>
                        <!--<Col :xs="24" :sm="12" :md="12" :lg="4">-->
                        <!--<Form-item>-->
                            <!--<Select size="large" v-model="searchForm.cpid"  placeholder="供应商简称" filterable>-->
                                <!--<Option value="">全部</Option>-->
                                <!--<Option v-for="(item,index) in cname_list" :value="item.cid" :key="item.cid">{{item.shortn}}</Option>-->

                            <!--</Select>-->
                        <!--</Form-item>-->
                        <!--</Col>-->
                        <!--<Col :xs="24" :sm="12" :md="12" :lg="3" style="padding-right:15px;">-->
                        <!--<Form-item>-->
                            <!--<Input size="large" type="text"  v-model="searchForm.name" placeholder="产品名称" />-->
                        <!--</Form-item>-->
                        <!--</Col>-->
                        <!-- <Col :xs="24" :sm="12" :md="12" :lg="3" style="padding-right:15px;">
                        <Form-item>
                            <Select size="large" v-model="searchForm.is_main" placeholder="主副险" @on-change="get_cate_two" >
                                <Option value="">全部</Option>
                                <Option value="1">主险</Option>
                                <Option value="2">附加险</Option>
                                <Option value="3">组合险</Option>
                            </Select>
                        </Form-item>
                        </Col>
                        <Col :xs="24" :sm="12" :md="12" :lg="3" style="padding-right:15px;">
                        <Form-item>
                            <Select size="large" v-model="searchForm.cate_one" placeholder="一级分类" @on-change="get_cate_two" >
                                <Option value="">全部</Option>
                                <template v-for="item in cate_first_list">
                                    <Option :value="item.id"  :key="item.id">{{item.cate_name}}</Option>
                                </template>
                            </Select>
                        </Form-item>
                        </Col>
                        <Col :xs="24" :sm="12" :md="12" :lg="3" style="padding-right:15px;">
                        <Form-item>
                            <Select size="large" v-model="searchForm.cate_two" placeholder="二级分类">
                                <Option value="">全部</Option>
                                <template v-for="item in cate_two_list">
                                    <Option :value="item.id"  :key="item.id">{{item.cate_name}}</Option>
                                </template>
                            </Select>
                        </Form-item>
                        </Col>
                        <Col :xs="24" :sm="12" :md="12" :lg="3" style="padding-right:15px;">
                        <Form-item>
                            <Select size="large" v-model="searchForm.status" placeholder="上架状态" >
                                <Option value="">不限</Option>
                                <Option value="1">上架</Option>
                                <Option value="2">未上架</Option>
                            </Select>
                        </Form-item>
                        </Col> -->
                        <!-- <Col :xs="24" :sm="12" :md="12" :lg="3" style="padding-right:15px;">
                        <Form-item>
                            <Select size="large" v-model="searchForm.is_hot"  placeholder="热门状态" filterable>
                                <Option value="">不限</Option>
                                <Option value="1">是</Option>
                                <Option value="0">否</Option>
                            </Select>
                        </Form-item>
                        </Col> -->
                        <i-col span="5">&emsp;</i-col>
                        <Col span="4" class="table-action pt0 pb0">
                        <Button type="success" size="large" class="fr" icon="plus" @click="modal5True">新增</Button>
                        <!-- <div style="border-right: 1px solid #EDF2F6;padding-right: 15px;margin-right: 15px;" class="fr">
                            <span class="clear"></span>

                            <Button size="large"  class="fr" type="info" icon="ios-search" @click="search">搜索</Button>

                        </div> -->

                        </Col>
                        <div class="clear"></div>
                    </Form>
                    <!-- <i-col span="24" class="table-action mb15">
                        <Button type="primary" size="large" class="fr" icon="icon iconfont icon-riqi" @click="headSet">
                            表头设置
                        </Button>
                    </i-col> -->
                    <!--<i-col span="24">-->
                    <!--<hr class="hr">-->
                    <!--</i-col>-->
                </Row>
            </div>
            <div class="table-theme highlight_table mt15">
                <Table :loading="tableloading" ref="currentRowTable" @on-current-change="tableCurrentChange($event)" size="large" stripe highlight-row border :columns="columns1" :data="prolist" class=""></Table>
            </div>
            <div id="footer">
            <Row class="pro-pagesize">
                <Col :md="24" :lg="16">
                <Button type="error" :disabled="tableaction" size="large" class="fl mr10 "   @click="remove">删除</Button>
                <!-- <Button type="warning" v-if="current.status" :disabled="tableaction" size="large" class="fl mr10"   @click="status_off">下架</Button> -->
                <!-- <Button type="success" v-if="!current.status" :disabled="tableaction" size="large" class="fl mr10"   @click="status_on">上架</Button> -->
                <Button type="primary" :disabled="tableaction" size="large" class="fl mr10"   @click="modal6True">编辑</Button>
                <!-- <Button type="warning" :disabled="tableaction" size="large" class="fl mr10"   @click="modal5True">保险责任</Button> -->

                <!-- <Button type="success" :disabled="tableaction" size="large" class="fl mr10"  >保险条款</Button> -->
                </Col>
                <Col :md="24" :lg="8" class="tRight">
                <Page ref="pages"  :total="listTotal" show-total show-sizer :page-size="pagesize" @on-change="pageChange" @on-page-size-change="pageSizeChange" placement="top" class="page"></Page>
                </Col>
            </Row>
        </div>
        </div>
        
        <!-- <Spin size="large" fix v-if="spinShow"></Spin> -->
        <Modal
            v-model="modal1"
            title="设置表格头部"
            ok-text="关闭"
            cancel-text=""
        >
            <CheckboxGroup v-model="tableHeadArray" @on-change="headSet">
                <template v-for="(item,index) in columnList">
                    <Checkbox :label="index" v-if="index!=='index'">{{item.title}}</Checkbox>
                </template>
            </CheckboxGroup>
        </Modal>
        <Modal
            v-model="modal5"
            title="新增保险责任"
            ok-text="保存设置"
            @on-ok="duty_create"
            :mask-closable="false"
            :width="500"
            cancel-text=""
            class="modal5"
            :loading="loading5"
        >
            <div class="pro">
                <div class="pro_show duty">
                    <Form :label-width="90" ref="dutyForm" :rules="dutyVallidate" :model="dutyForm">
                        <Row class="" style="padding:0 5px 10px;">
                            <i-col span="24">
                                <FormItem label="产品名称" prop="mid">
                                    <i-select disabled v-model="dutyForm.mid">
                                        <i-option :value="dutyForm.mid" :key="dutyForm.mid">{{dutyForm.pro_name}}</i-option>
                                    </i-select>
                                </FormItem>
                            </i-col>
                            <i-col span="24">
                                <FormItem label="责任名称" prop="name">
                                    <i-input placeholder="请输入责任名称" v-model="dutyForm.name"></i-input>
                                </FormItem>
                            </i-col>
                            <i-col span="24">
                                <FormItem label="最高保障" prop="">
                                    <i-input placeholder="请输入最高保障，例如：100万" v-model="dutyForm.max_security"></i-input>
                                </FormItem>
                            </i-col>
                            <i-col span="24">
                                <i-input type="textarea" :rows="4" placeholder="请输入责任内容" v-model="dutyForm.content"></i-input>
                            </i-col>
                        </Row>
                    </Form>
                </div>
            </div>
        </Modal>
        <Modal
            v-model="modal6"
            title="新增保险责任"
            ok-text="保存设置"
            @on-ok="duty_update"
            :mask-closable="false"
            :width="500"
            cancel-text=""
            class="modal6"
            :loading="loading6"
        >
            <div class="pro">
                <div class="pro_show duty">
                    <Form :label-width="90" ref="update_duty" :rules="dutyVallidate" :model="update_duty">
                        <Row class="" style="padding:0 5px 10px;">
                            <i-col span="24">
                                <FormItem label="产品名称" prop="mpid">
                                    <i-select disabled v-model="update_duty.mpid">
                                        <i-option :value="update_duty.mpid" :key="update_duty.mpid">{{update_duty.pname}}</i-option>
                                    </i-select>
                                </FormItem>
                            </i-col>
                            <i-col span="24">
                                <FormItem label="责任名称" prop="name">
                                    <i-input placeholder="请输入责任名称" v-model="update_duty.name"></i-input>
                                </FormItem>
                            </i-col>
                            <i-col span="24">
                                <FormItem label="最高保障" prop="max_security">
                                    <i-input placeholder="请输入最高保障，例如：100万" v-model="update_duty.max_security"></i-input>
                                </FormItem>
                            </i-col>
                            <i-col span="24">
                                <i-input type="textarea" :rows="4" placeholder="请输入责任内容" v-model="update_duty.content"></i-input>
                            </i-col>
                        </Row>
                    </Form>
                </div>
            </div>
        </Modal>
    </div>
</template>

<script>
    import productTitle from '../../components/productTitle'

    import {getComlist ,getCompany,get_cate_first ,get_cate_second,getCompany1} from '../../api/parter'
    import {getProList,delPro ,shangjia} from '../../api/product_v2'



    import {get_list} from '../../api/product_v2'
    import { getStsTokenWrite,getStsTokenRead } from '../../api/common';



    //新
    import {_duty_list,_duty_create,_duty_delete,_duty_info,_duty_update} from '../../api/product_v2'
    import VueCropper from 'vue-cropper';
    export default {
        data() {
            return {
                //表头设置
                modal1:false,
                //搜索的表格数据
                searchForm: {
                    cpid:'',
                    cate_first:'',
                    cate_two:'',
                    name:'',
                    is_main:'',
                    status:'',
                    p:'',
                    pagesize:'',
                    pay_period:''
                },
                columnList:{
                    index:{
                        type: 'index',
                        title:'序号',
                        width: 60,
                        align: 'center',
                    },
                    name:{
                        title: '产品名称',
                        key: 'name',
                        align:'center'
                    },
                    cname:{
                        title: '供应商',
                        key: 'cname',
                        align:'center'
                    },
                    is_main:{
                        title: '主附险类型',
                        key: 'is_main',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                            },params.row.is_main == 1?'主险':'附加险')
                        }
                    },
                    cate_one:{
                        title: '分类',
                        key: 'cate_one',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{},params.row.cate_one+'/'+params.row.cate_two)
                        }
                    },
                    limit_age:{
                        title: '承保年龄',
                        key: 'limit_age',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                                props:{
                                    className:"nowrap"
                                },
                            },params.row.limit_age?params.row.limit_age:'暂无')
                        }
                    },
                    pay_period:{
                        title: '交费期间',
                        key: 'pay_period',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                                attrs:{
                                    class:"nowrap"
                                },
                            },params.row.pay_period?params.row.pay_period:'暂无')
                        }
                    },
                    period:{
                        title: '保险期间',
                        key: 'period',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                                attrs:{
                                    class:"nowrap"
                                },
                            },params.row.period?params.row.period:'暂无')
                        }
                    },
                    is_hot:{
                        title: '是否热门',
                        key: 'is_hot',
                        render:(h,params)=>{
                            return h('div',{
                                    attrs:{
                                        class: params.row.is_hot=='1'?'success-color':''
                                    }
                                },
                                params.row.is_hot=='1'?'是':'否')
                        },
                        align:'center'
                    },
                    status:{
                        title: '上架状态',
                        key: 'status',
                        render:(h,params)=>{
                            return h('div',{
                                    attrs:{
                                        class: params.row.status== '上架' ?'success-color':'nopass-color'
                                    }
                                },
                                params.row.status== '上架' ?'上架':'未上架')
                        },
                        align:'center'
                    },
                },
                columns1: [
                    {
                        type: 'index',
                        title:'序号',
                        width: 60,
                        align: 'center',
                    },
                   {
                       title: '保险责任名称',
                       key: 'name',
                       align:'center',
                       width:150,
                   },
                    {
                        title: '责任内容',
                        key: 'content',
                        align:'center',
                        
                    },
                    {
                        title: '最高保障',
                        key: 'max_security',
                        align:'center',
                        width:150,
                    },
                    {
                        title: '创建时间',
                        key: 'create_timed',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',params.row.create_timed.slice(0,10))
                        },
                        width:150,
                    },
                    {
                        title: '修改时间',
                        key: 'update_timed',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',params.row.update_timed.slice(0,10))
                        },
                         width:150,
                    }
                ],
                prolist:[],
                cateOneAll: [], //一级分类列表
                comlist:[],
                listTotal: 0, //产品总数
                p:1,
                pagesize:10,
                cname_list:[],
                cate_first_list:[],
                cate_two_list:[],
                current:{},
                tableHeadArray:["name","cname","is_main","cate_one","limit_age","pay_period","period","is_hot","status"],
                tableloading:true,
                tableaction:true,
                modal5:false,
                dutyForm:{
                    mid:'',
                    pro_name:'',
                    max_security:'',
                    content:'',
                    name:'',
                },
                update_duty:{
                    max_security:'',
                    content:'',
                    name:'',
                    mid:'',
                    mpid:'',
                    pname:'',
                },
                dutyVallidate:{
                    mid:[
                        {
                            required:true,message:'产品名称不能为空'
                        }
                    ],
                    mpid:[
                        {
                            required:true,message:'产品名称不能为空'
                        }
                    ],
                    name:[
                        {
                            required:true,message:'责任名称不能为空'
                        }
                    ],
                    max_security:[
                        {
                            required:true,message:'最高保障不能为空'
                        }
                    ],
                    content:[
                        {
                            required:true,message:'内容不能为空'
                        }
                    ]
                },
                modal6:false,
                loading5:true,
                loading6:true,
            };
        },
        components: {
            productTitle,
        },
        computed:{
        },
        created() {
        },
        mounted () {
            // this.$nextTick(function () {
            //     document.getElementById('footer').style.width = getComputedStyle(document.getElementsByClassName('pro-list')[0]).width;
            // })
        },
        activated(){
            this.dutyForm.mid=this.$route.params.id;
            this.dutyForm.pro_name=this.$route.params.name;
            this.getList();
//            this.all_company();
//            this.get_cate_one();
        },
        methods: {
            modal2True(){
                this.modal2=true;
                this.get_pro_img();
            },
            headSet(){
                this.modal1=true;
                let columnList={
                    index:{
                        type: 'index',
                        title:'序号',
                        width: 60,
                        align: 'center',
                    },
                    pro_name:{
                        title: '产品名称',
                        key: 'pro_name',
                        align:'center'
                    },
                    cname:{
                        title: '供应商',
                        key: 'cname',
                        align:'center'
                    },
                    is_main:{
                        title: '主附险类型',
                        key: 'is_main',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                            },params.row.is_main == 1?'主险':'附加险')
                        }
                    },
                    cate_one:{
                        title: '分类',
                        key: 'cate_one',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{},params.row.cate_one+'/'+params.row.cate_two)
                        }
                    },
                    limit_age:{
                        title: '承保年龄',
                        key: 'limit_age',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                                props:{
                                    className:"nowrap"
                                },
                            },params.row.limit_age?params.row.limit_age:'暂无')
                        }
                    },
                    pay_period:{
                        title: '交费期间',
                        key: 'pay_period',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                                attrs:{
                                    class:"nowrap"
                                },
                            },params.row.pay_period?params.row.pay_period:'暂无')
                        }
                    },
                    period:{
                        title: '保险期间',
                        key: 'period',
                        align:'center',
                        render:(h,params)=>{
                            return h('div',{
                                attrs:{
                                    class:"nowrap"
                                },
                            },params.row.period?params.row.period:'暂无')
                        }
                    },
                    is_hot:{
                        title: '是否热门',
                        key: 'is_hot',
                        render:(h,params)=>{
                            return h('div',{
                                    attrs:{
                                        class: params.row.is_hot=='1'?'success-color':''
                                    }
                                },
                                params.row.is_hot=='1'?'是':'否')
                        },
                        align:'center'
                    },
                    status:{
                        title: '上架状态',
                        key: 'status',
                        render:(h,params)=>{
                            return h('div',{
                                    attrs:{
                                        class: params.row.status=='上架'?'success-color':'nopass-color'
                                    }
                                },
                                params.row.status=='上架'?'上架':'未上架')
                        },
                        align:'center'
                    },
                };
                this.columns1 = [
                    {
                        type: 'index',
                        title:'序号',
                        width: 60,
                        align: 'center',
                    }
                ];
                this.tableHeadArray.map(item=>{
                    this.columns1.push(columnList[item]);
                })
            },
            tableCurrentChange(currentRow,oldCurrentRow){
                this.tableaction = false;
                this.current = currentRow;
//            this.current.id = currentRow._id
//            this.current.name = currentRow.name
//
//            this.current.status = currentRow.status == 1 ? true : false
                this.$set(this.current,'status',currentRow.status  == '上架' ? true : false)
//            console.log( this.current.status)
//            console.log(currentRow)
            },

            //上架
            status_on(){
                let _params = {
                    mid:this.current.id
                }
                new Promise((resolve,reject)=>{
                    _status_on(_params).then(response =>{
                        if(response.data.err==0){
                            this.getList();
                        }else{
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error=>{
                        reject(error);
                    })
                })

            },
            //下架
            status_off(){
                let _params = {
                    mid:this.current.id
                }
                new Promise((resolve,reject)=>{
                    _status_off(_params).then(response =>{
                        if(response.data.err==0){
                            this.getList();
                        }else{
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error=>{
                        reject(error);
                    })
                })
            },
            get_cate_one(){
                new Promise((resolve,reject)=>{
                    _cate_first().then(res=>{
                        if(res.data.err==0){
                            this.cate_first_list=res.data.data;
                        }else{
//                        this.$Message.error(res.data.info);
                        }
                        resolve();
                    }).catch(error=>{
                        reject(error);
                    })
                })
            },
            get_cate_two(){
                let params = {
                    id:this.searchForm.cate_first
                }
                new Promise((resolve,reject)=>{
                    _cate_second(params).then(res=>{
                        if(res.data.err==0){
                            this.cate_two_list = res.data.data;
                        }else{
//                        this.$Message.error(res.data.info);
                        }
                        resolve();
                    }).catch(error=>{
                        reject(error);
                    })
                })
            },
            all_company(){
                new Promise((resolve,reject)=>{
                    _get_parter_list().then(res=>{
                        if(res.data.err==0){
                            this.cname_list = res.data.data;
                            //this.searchForm.cpid = this.$route.query.cpid
                        }else{
                            this.$Message.error(res.data.info);
                        }
                        resolve();
                    }).catch(error=>{
                        reject(error);
                    })
                })
            },
            search(){
                this.searchForm.p = 1
                this.p = 1
                this.searchForm.pagesize=this.pagesize;
                this.tableaction = true
                this.searchForm.p=this.p;
                let _query = Object.assign({},this.searchForm,{p:1,pagesize: this.pagesize})
                this.$router.push({name:'pro',query:_query})
                this.getList(-1)
            },
            getList(id) {
                this.searchForm.p=this.$route.query.p;
                this.searchForm.pagesize=this.pagesize;
                this.searchForm.mid = this.dutyForm.mid;
                new Promise((resolve, reject) => {
                    _duty_list(this.searchForm).then(response => {
                        if(response.data.err==0){
                            this.prolist=[];
                            this.listTotal = response.data.data.total;
                            if(id == -1){
                                this.$refs['pages'].currentPage = 1
                            }
                            this.prolist = response.data.data.list;
                            this.tableloading = false
                        }else{
                            this.$Message.error(response.data.info);
                        }
                        resolve();
                    }).catch(error => {
                        reject(error);
                    });
                });
            },
            remove() {
                this.$Modal.confirm({
                    title: '提示',
                    content: '是否要删除该条记录?',
                    onOk: () => {
                        this.duty_del();
                    },
                });

            },
            pageChange(value) {
                this.p = value;
                let _query = Object.assign({},this.searchForm,{p:value,pagesize: this.pagesize})
                console.log(_query)
                this.$router.push({name:'pro',query:_query})
                this.getList();
            },
            pageSizeChange(value) {
                this.pagesize = value;
                this.getList();
            },
            //保险责任
            modal5True(){
                this.modal5=true;
            },
            modal6True(){
                this.modal6=true;
                this.toDetail();
            },
            duty_create(){
                this.$refs['dutyForm'].validate((valid) => {
                    if (valid) {

                        new Promise((resolve,reject)=>{
                            _duty_create(this.dutyForm).then(res=>{
                                if(res.data.err==0){
                                    this.getList();
                                    this.dutyForm.name='';
                                    this.dutyForm.content='';
                                    this.dutyForm.max_security='';
                                    this.$refs['dutyForm'].resetFields();
                                    this.modal5=false;
                                }else{
                                    this.$Message.error(res.data.info);
                                }
                                resolve();
                            }).catch(error=>{
                                reject(error);
                            })
                        })
                    } else {
                        this.$Message.error('参数不能为空!');
                        let _this=this;
                        _this.loading5=false;
                        setTimeout(function(){
                            _this.$nextTick(function(){
                                _this.loading5=true;
                            })
                        },1000)
                    }
                })

            },
            duty_del(){
                let params={
                    duty_id:this.current.id
                }
                new Promise((resolve,reject)=>{
                    _duty_delete(params).then(res=>{
                        if(res.data.err==0){
                            this.$Message.success('操作成功');
                            this.getList();
                        }else{
                            this.$Message.error(res.data.info);
                        }
                        resolve();
                    }).catch(error=>{
                        reject(error);
                    })
                })
            },
            //编辑
            toDetail(){
                let params ={
                    duty_id:this.current.id
                }
                new Promise((rev,rej)=>{
                    _duty_info(params).then(res=>{
                        this.update_duty.duty_id = res.data.data.id;
                        this.update_duty.mpid = res.data.data.pid;
                        this.update_duty.pname = res.data.data.pname;
                        this.update_duty.name = res.data.data.name;
                        this.update_duty.content = res.data.data.content;
                        this.update_duty.max_security = res.data.data.max_security;
                        rev();
                    }).catch(error=>{
                        rej(error);
                    })
                })
            },
            duty_update(){
                this.$refs['update_duty'].validate((valid) => {
                    if (valid) {
                        new Promise((resolve,reject)=>{
                            _duty_update(this.update_duty).then(res=>{
                                if(res.data.err==0){
                                    this.getList();
                                    this.update_duty.duty_id = '';
                                    this.update_duty.mpid = "";
                                    this.update_duty.pname = '';
                                    this.update_duty.name ='';
                                    this.update_duty.content = '';
                                    this.update_duty.max_security = '';
                                    this.$refs['update_duty'].resetFields();
                                    this.modal6=false;
                                }else{
                                    this.$Message.error(res.data.info);
                                }
                                resolve();
                            }).catch(error=>{
                                reject(error);
                            })
                        })
                    } else {
                        this.$Message.error('参数不能为空!');
                        let _this=this;
                        _this.loading6=false;
                        setTimeout(function(){
                            _this.$nextTick(function(){
                                _this.loading6=true;
                            })
                        },1000)
                    }
                })
            }
        }

    };
</script>
